package com.kaishengit.web;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kaishengit.dao.IdeaDao;
import com.kaishengit.dao.ProjectDao;
import com.kaishengit.entity.Idea;
import com.kaishengit.entity.Project;

public class IdeaServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		int projectid = Integer.parseInt(request.getParameter("projectid"));
		Project p = new Project();
		ProjectDao pdao = new ProjectDao();
		p = pdao.findByProjectId(projectid);
		List<Idea> ilist = new ArrayList<Idea>();
		IdeaDao idao = new IdeaDao();
		ilist = idao.findByProjectId(projectid);
		request.setAttribute("project", p);
		request.setAttribute("idealist", ilist);
		request.getRequestDispatcher("WEB-INF/views/idea.jsp").forward(request, response);
		

	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	}

}
